<template>
  <div>
    <TopFilter :list="topFilterList" :cols="2" :collapse="false" :isSubmitBtn="false" @filterChange="changeHandle"></TopFilter>
  </div>
</template>
<script>
export default {
  props: ['getdata'],
  data() {
    return {
      topFilterList: this.createdFrom()
    };
  },
  watch: {
    getdata: {
      handler: function(newval, oldVal) {
        if (newval.type == 'add') {
          this.topFilterList.map((item, key) => {
            item.disabled = false;
          });
        } else if (newval.type == 'emit') {
          this.initData();
          console.log(newval, '统计');
          // this.topFilterList.map((item, key) => {
          //   item.disabled = false;
          // });
        } else {
          this.topFilterList.forEach(x => {
            x.initialValue = '';
          });
          this.topFilterList.map((item, key) => {
            item.disabled = true;
          });
        }
      },
      deep: true
    }
  },
  methods: {
    createdFrom() {
      return [
        {
          type: 'INPUT',
          label: '应收:工时费',
          fieldName: 'LABOUR_AMOUNT',
          initialValue: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '维修材料费',
          fieldName: 'PART_SALES_AMOUNT',
          initialValue: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '实收:工时费',
          fieldName: 'shishou',
          initialValue: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '维修材料费',
          fieldName: 'REPAIR_PART_AMOUNT',
          initialValue: '',
          disabled: true
        }
      ];
    },
    changeHandle(val) {},
    initData() {
      this.topFilterList.forEach(x => {
        x.initialValue = this.getdata[x.fieldName];
      });
    }
  }
};
</script>
